import { defineStore } from "pinia";

import { getStudentList, addStudent, updateStudent, deleteStudent } from "../api/student";


export const useStudentStore = defineStore("student", {
    state: () => {
        return {
            studentList: [] as IStudent[],
            currentPage: 1,
            pageSize: 10,
            total: 0,
        }
    },
    actions: {
        async fetchStudentList() {
            const res = await getStudentList(this.currentPage, this.pageSize)
            this.studentList = res.data.students
            this.total = res.data.total
        },
    },
    getters: {
        getStudentList: (state) => {
            return state.studentList
        }
    }
})